import { Modal } from 'ant-design-vue';

export function msgModal(info: {
  msg: string;
  title?: string;
  onOk?: () => void;
  onCancel?: () => void;
  type?: 'info' | 'success' | 'error' | 'warn' | 'warning' | 'confirm' | undefined;
}) {
  Modal[info.type || 'error']({
    // type: info.type || 'error',
    title: info.title || '警告',
    content: info.msg,
    onOk: info.onOk,
    onCancel: info.onCancel,
    okText: '确认',
    cancelText: '取消',
  });
}

export const getMenuImageUrl = (img: string) => {
  return new URL(`../assets/images/menus/${img}`, import.meta.url).href;
  // if (import.meta.env.VITE_ENV === 'development') {
  //   return new URL(`../assets/images/menus/${img}`, import.meta.url).href;
  // } else {
  //   return `https://static.lingzhuyunpms.cn/cashier/assets/images/menus/${img}`;
  // }
};
